package com.zhongyu.boot;


import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitMQConfig {

    public static final String ITEM_DIRECT_EXCHANGE="item_direct_exchange";
    public static final String ITEM_DIRECT_QUEUE01="item_direct_queue01";
    public static final String ITEM_DIRECT_QUEUE02="item_direct_queue02";

    @Bean("item_direct_exchange")
    public Exchange bootExchange(){
        return ExchangeBuilder.directExchange(ITEM_DIRECT_EXCHANGE).durable(true).build();
    }

    @Bean("item_direct_queue01")
    public Queue bootQueue01(){
        return QueueBuilder.durable(ITEM_DIRECT_QUEUE01).build();
    }

    @Bean("item_direct_queue02")
    public Queue bootQueue02(){
        return QueueBuilder.durable(ITEM_DIRECT_QUEUE02).build();
    }

    @Bean("item_add_binding")
    public Binding bootItemAddBinding(){
        return BindingBuilder.bind(bootQueue01()).to(bootExchange()).with("item.add").noargs();
    }

    @Bean("item_update_binding")
    public Binding bootItemUpdateBinding(){
        return BindingBuilder.bind(bootQueue02()).to(bootExchange()).with("item.update").noargs();
    }


}
